<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>用户登录</title>
    <script>
        document.addEventListener('DOMContentLoaded', function() {
            var form = document.getElementById('loginForm');
            form.addEventListener('submit', function(e) {
                e.preventDefault(); // 阻止表单默认提交行为
                var email = document.getElementById('email').value;
                var password = document.getElementById('password').value;
                var user = {email: email, password: password};

                fetch('/login/bypasswd', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json',
                    },
                    body: JSON.stringify(user),
                })
                    .then(response => response.json())
                    .then(data => {
                        if (data.code === 200) {
                            alert('登录成功！');
                            // 这里可以添加登录成功后的逻辑，比如跳转到另一个页面
                        } else {
                            alert('登录失败：' + data.message);
                        }
                    })
                    .catch(error => {
                        console.error('Error:', error);
                    });
            });
        });
    </script>
</head>
<body>
<form id="loginForm">
    <div class="form-group">
        <label for="email">邮箱:</label>
        <input type="email" id="email" name="email" required>
    </div>
    <div class="form-group">
        <label for="password">密码:</label>
        <input type="password" id="password" name="password" required>
    </div>
    <div class="form-group">
        <button type="submit">登录</button>
    </div>
    <img src="http://localhost:9999/game/resource?gid=15&fileName=1.png" height="200px" width="300px" alt="无">
</form>
</body>
</html>